package com.rockcent.mall.lib.repository;

import com.rockcent.mall.lib.domain.MerchantFund;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;

/**
 * Created by oyhk on 14-6-22.
 */
@Repository
public interface MerchantFundRepository extends JpaRepository<MerchantFund, Long>, JpaSpecificationExecutor, MerchantFundRepositoryCustom {

    MerchantFund findByMallIdAndMerchantId(Long mallId, Long merchantId);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    MerchantFund findOne(Long id);

    MerchantFund findTop1ByMerchantId(Long merchantId);
}
